<!DOCTYPE html>
<html>
<head>
    <title>Azure Table Storage Query Question</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
        }
        .question {
            background-color: #f5f5f5;
            padding: 15px;
            border-radius: 5px;
            margin-bottom: 20px;
        }
        .options {
            margin-left: 20px;
            margin-bottom: 20px;
        }
        .option {
            margin-bottom: 10px;
        }
        button {
            background-color: #0078d4;
            color: white;
            border: none;
            padding: 10px 15px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
        }
        button:hover {
            background-color: #106ebe;
        }
        .answer {
            margin-top: 20px;
            padding: 15px;
            background-color: #e6f2ff;
            border-radius: 5px;
            display: none;
        }
        .correct {
            color: green;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div class="question">
        <h2>QUESTION NO: 121</h2>
        <p>You use Azure Table storage to store customer information for an application. The data contains customer details and is partitioned by last name. You need to create a query that returns all customers with the last name Smith. Which code segment should you use?</p>
        
        <div class="options">
            <div class="option">
                <input type="radio" id="optionA" name="answer" value="A">
                <label for="optionA">A. TableQuery.GenerateFilterCondition("PartitionKey", Equals, "Smith")</label>
            </div>
            
            <div class="option">
                <input type="radio" id="optionB" name="answer" value="B">
                <label for="optionB">B. TableQuery.GenerateFilterCondition("LastName", Equals, "Smith")</label>
            </div>
            
            <div class="option">
                <input type="radio" id="optionC" name="answer" value="C">
                <label for="optionC">C. TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "Smith")</label>
            </div>
            
            <div class="option">
                <input type="radio" id="optionD" name="answer" value="D">
                <label for="optionD">D. TableQuery.GenerateFilterCondition("LastName", QueryComparisons.Equal, "Smith")</label>
            </div>
        </div>
        
        <button id="showAnswer">查看答案</button>
        
        <div id="answerSection" class="answer">
            <p><span class="correct">正确答案: C</span></p>
            <p><strong>说明:</strong></p>
            <p>题目中提到数据是按姓氏(last name)分区的，这意味着姓氏被用作分区键(PartitionKey)。在Azure Table Storage中，查询特定分区的数据应该使用PartitionKey而不是具体的属性名。</p>
            <p>正确的语法是使用TableQuery.GenerateFilterCondition方法，并指定QueryComparisons.Equal作为比较操作符。"Equals"不是有效的比较操作符。</p>
            <p>示例代码:</p>
            <pre>
// Construct the query operation for all customer entities where PartitionKey="Smith"
TableQuery&lt;CustomerEntity&gt; query = new TableQuery&lt;CustomerEntity&gt;()
    .Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "Smith"));
            </pre>
            <p>参考文档: <a href="https://docs.microsoft.com/en-us/azure/cosmos-db/table-storage-how-to-use-dotnet" target="_blank">Azure Table Storage documentation</a></p>
        </div>
    </div>

    <script>
        document.getElementById('showAnswer').addEventListener('click', function() {
            var answerSection = document.getElementById('answerSection');
            if (answerSection.style.display === 'none') {
                answerSection.style.display = 'block';
            } else {
                answerSection.style.display = 'none';
            }
        });
    </script>
</body>
</html>
